﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;

namespace WebSite
{
    public class SQLAccess
    {
        // Fields
        private static string DBConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();

        public static DataSet GreatDs(string sql)
        {
           SqlDataAdapter adapter = new SqlDataAdapter(sql, DBConnectionString);
            DataSet dataSet = new DataSet();
            adapter.Fill(dataSet);
            return dataSet;
        }

        public static string languages(string str)
        {
            string sql = "Select * From DB_Language Where visible =0";
            DataTable table = GreatDs(sql).Tables[0];
            if (table.Rows.Count > 0)
            {
                foreach (DataRow row in table.Rows)
                {
                    str = str + "," + row["languageid"].ToString();
                }
            }
            return str.Trim();
        }

        public static string languagesa(string str)
        {
            string sql = "Select * From DB_Language Where visible =1 and istrue=1";
            DataTable table = GreatDs(sql).Tables[0];
            if (table.Rows.Count > 0)
            {
                foreach (DataRow row in table.Rows)
                {
                    str = str + "," + row["languageid"].ToString();
                }
            }
            return str.Trim();
        }

        public static string languagesab(string str)
        {
            string sql = "Select * From DB_Language Where visible =1";
            DataTable table = GreatDs(sql).Tables[0];
            if (table.Rows.Count > 0)
            {
                foreach (DataRow row in table.Rows)
                {
                    str = str + "," + row["languageid"].ToString();
                }
            }
            return str.Trim();
        }
        // Methods
        public static void DoSql(string sql)
        {

            SqlConnection connection = new SqlConnection
            {
                ConnectionString = DBConnectionString
            };
            connection.Open();
            new SqlCommand(sql, connection).ExecuteNonQuery();
            connection.Close();
        }


    }
}